package com.vpx.server.bean.entity;

import cn.hutool.core.bean.BeanUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @author chenshuli
 * @date 2023/4/9 11:29
 */
@Data
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 4321416915459158632L;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    public <T extends BaseEntity> T from(Object o) {
        if (o != null) {
            BeanUtil.copyProperties(o, this);
        }
        return (T) this;
    }

}
